package com.jomoo.css.common.util.client;

import com.jomoo.css.common.util.dto.SysDepartmentDTO;
import com.jomoo.css.common.util.dto.SysEmployeeDTO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.Map;
import java.util.Set;

@FeignClient(value = "runtime",contextId = "ou",fallback = SYSOUFallback.class)
public interface SYSOUFeignClient
{
	/**
	 * 从ou中获取当前上下级组织、部门信息
	 * @param userId
	 * @return
	 */
	@GetMapping("/sysemployees/{userId}/oumaps")
	Map<String, Set<String>> getOUMapsByUserId(@PathVariable("userId") String userId);

	/**
	 * 创建/更新部门
	 * @param sysdepartmentdto
	 * @return
	 */
	@RequestMapping(method = RequestMethod.POST, value = "/sysdepartments/save")
	ResponseEntity<Boolean> saveDept(@RequestBody SysDepartmentDTO sysdepartmentdto);

	/**
	 * 创建/更新人员
	 * @param sysemployeedto
	 * @return
	 */
	@RequestMapping(method = RequestMethod.POST, value = "/sysemployees/save")
	ResponseEntity<Boolean> saveEmp(@Validated @RequestBody SysEmployeeDTO sysemployeedto);
	
	/**
	 * 删除人员
	 * @param sysemployee_id
	 * @return
	 */
	@RequestMapping(method = RequestMethod.DELETE, value = "/sysemployees/{sysemployee_id}")
	ResponseEntity<Boolean> removeEmp(@PathVariable("sysemployee_id") String sysemployee_id);
	
	/**
	 * 同步人员的角色字段
	 * @param userId
	 * @param roles
	 * @param addOrRemove
	 * @return
	 */
	@RequestMapping(method = RequestMethod.POST, value = "/sysemployees/syncuserroles/{userid}/{addorremove}")
	ResponseEntity<Boolean> syncUserRoles(@PathVariable("userid") String userId, @RequestBody(required = false) String roles, @PathVariable("addorremove") String addOrRemove);

}
